<template>
  <div class="child">
    <h3>子组件1</h3>
    <h4>玩具:{{ toy }}</h4>
    <h4>书籍:{{ book }}本</h4>
    <button @click="minusHouse($parent)">干掉父亲一套房产</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
//数据
let toy = ref("暴龙战士");
let book = ref(3);

//把数据交给外部(儿子允许自己父亲动)
defineExpose({ toy, book });
function minusHouse(parent: any) {
  console.log(parent);
  parent.house--;
}
</script>

<style scoped>
.child {
  background: skyblue;
  padding: 10px;
  box-shadow: 0 0 10px black;
  border-radius: 10px;
}
</style>
